/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.nicmodule.core;

import org.testis.utils.OsInfo;

/**Abstraction class for bridge pattern
 * Responsible for abstract methods and interface setter and os type
 * @author alperb
 */
public abstract class NetworkInterfaceController {

    private NetworkOS m_networkOs;
    protected String m_interfaceName;

    protected void setInterfaceName(String s) {
        this.m_interfaceName = s;
    }

    protected void setNetworkOS() {

        if (OsInfo.isWindows()) {
            m_networkOs = (NetworkOS) new NetworkOSWindows();
        } else if (OsInfo.isLinux()) {
            m_networkOs = (NetworkOS) new NetworkOSLinux();
        } else {
            throw new NicModuleException(NicModuleExceptionType.UNSUPPORTEDOS,
                    "Running on unsupported OS...");
        }
    }

    public  boolean isInterfaceExists() {
        return getNetworkOs().isInterfaceExists(m_interfaceName);
    }

    public abstract boolean verifyInterfaceConfiguration(String ip,
            String gateWay,
            String dns,
            String Subnet,
            String messageId);

    public abstract boolean setAndVerifyInterfaceConfiguration(String ip,
            String gateWay,
            String dns,
            String Subnet,
            Boolean fromDhcp,
            String messageId);

    public abstract boolean renewDhcpConfiguration();

    public abstract boolean adjustInterface(boolean toUp);

    public NetworkOS getNetworkOs() {
        return m_networkOs;
    }
}


